<template>
  <template v-if="user">
    <van-cell title="昵称" :value="user.username" @click="toEdit('username' ,'昵称',user.username)"/>
    <van-cell title="账号" :value="user.userAccount" />
    <van-cell title="头像" >
      <img style="height: 48px" :src="user.avatarUrl"/>
    </van-cell>
    <van-cell title="性别" is-link :value="user.gender" @click="toEdit('gender' ,'性别',user.gender)"/>
    <van-cell title="电话" is-link :value="user.phone" @click="toEdit('phone' ,'电话',user.phone)"/>
    <van-cell title="邮箱" is-link :value="user.email" @click="toEdit('email' ,'邮箱',user.email)"/>
    <van-cell title="标签" is-link :value="user.tags" @click="toEdit('tags' ,'标签',user.tags)"/>
    <van-cell title="星球编号"  :value="user.planetCode"/>
    <van-cell title="注册时间"  :value="user.createTime"/>
  </template>
</template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import myAxios from "../../plugins/myAxios";
import {showFailToast, showSuccessToast} from "vant";
import {getCurrentUser} from "../services/user";

// const user = {
//   id: 1,
//   username: '蓝莓',
//   userAccount: 'lanMei',
//   avatarUrl: 'src/img/yln.jpg',
//   gender: '男',
//   phone: '123456',
//   email: '123456@qq.com',
//   planetCode: '1',
//   createTime: new Date(),
// }
const user = ref();
onMounted(async () =>{
  const res= await getCurrentUser();
  user.value = res.data;
})

const router = useRouter();

const toEdit = (editKey: string,editName: string,currentValue: string) =>{
  router.push({
    path:'/user/edit',
    query:{
      editKey,
      editName,
      currentValue,
    }
  })
}
</script>

<style scoped>

</style>